using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
using SJVars;
using Spacejock;
using System;
using System.Collections;
using System.Runtime.CompilerServices;
using System.Threading;
using yW5Lib;

namespace yWriter6
{
	public class clsPrintNotes
	{
		public delegate void PrintProgressEventHandler(string ProgressString);

		[CompilerGenerated]
		private PrintProgressEventHandler PrintProgressEvent;

		public event PrintProgressEventHandler PrintProgress
		{
			[CompilerGenerated]
			add
			{
				PrintProgressEventHandler printProgressEventHandler = PrintProgressEvent;
				PrintProgressEventHandler printProgressEventHandler2;
				do
				{
					printProgressEventHandler2 = printProgressEventHandler;
					PrintProgressEventHandler value2 = (PrintProgressEventHandler)Delegate.Combine(printProgressEventHandler2, value);
					printProgressEventHandler = Interlocked.CompareExchange(ref PrintProgressEvent, value2, printProgressEventHandler2);
				}
				while ((object)printProgressEventHandler != printProgressEventHandler2);
			}
			[CompilerGenerated]
			remove
			{
				PrintProgressEventHandler printProgressEventHandler = PrintProgressEvent;
				PrintProgressEventHandler printProgressEventHandler2;
				do
				{
					printProgressEventHandler2 = printProgressEventHandler;
					PrintProgressEventHandler value2 = (PrintProgressEventHandler)Delegate.Remove(printProgressEventHandler2, value);
					printProgressEventHandler = Interlocked.CompareExchange(ref PrintProgressEvent, value2, printProgressEventHandler2);
				}
				while ((object)printProgressEventHandler != printProgressEventHandler2);
			}
		}

		public void PrintNoteList(clsProject cProject)
		{
			Collection collection = new Collection();
			IEnumerator enumerator = default(IEnumerator);
			try
			{
				enumerator = cProject.Notes.GetEnumerator();
				while (enumerator.MoveNext())
				{
					clsNote clsNote = (clsNote)enumerator.Current;
					collection.Add(clsNote.ID);
				}
			}
			finally
			{
				if (enumerator is IDisposable)
				{
					(enumerator as IDisposable).Dispose();
				}
			}
			PrintNotes(cProject, collection);
		}

		public void PrintNotes(clsProject cProject, Collection NoteIDs)
		{
			//Discarded unreachable code: IL_018c, IL_01a3, IL_01ae, IL_01be, IL_0244, IL_0246, IL_025a, IL_027c
			int num = default(int);
			int num3 = default(int);
			try
			{
				ProjectData.ClearProjectError();
				num = 2;
				int num2 = 2;
				clsShared.cSubs.BusyMouse();
				num2 = 3;
				clsReport clsReport = new clsReport(ref clsShared.cLog, ref clsShared.cSettings, "Project Notes");
				num2 = 4;
				clsReport.AddTitle();
				num2 = 5;
				clsReport.AddCentered(cProject.Title + " by " + cProject.AuthorName);
				num2 = 6;
				clsReport.AddBR(2);
				num2 = 7;
				clsReport.SetTableBorder(1);
				num2 = 8;
				clsReport.OpenTable("cellpadding=5");
				num2 = 9;
				clsReport.OpenRow();
				num2 = 10;
				clsReport.AddCell("<b>Title</b>", clsReport.Class_Header);
				num2 = 11;
				clsReport.AddCell("<b>Description</b>", clsReport.Class_Header);
				num2 = 12;
				clsReport.CloseRow();
				num2 = 13;
				IEnumerator enumerator = NoteIDs.GetEnumerator();
				while (enumerator.MoveNext())
				{
					int iD = Conversions.ToInteger(enumerator.Current);
					num2 = 14;
					clsNote clsNote = cProject.get_NoteByID(iD);
					num2 = 15;
					if (clsNote != null)
					{
						num2 = 16;
						clsReport.OpenRow();
						num2 = 17;
						clsReport.AddCell(clsNote.Title);
						num2 = 18;
						clsReport.AddCell(clsNote.DescText);
						num2 = 19;
						clsReport.CloseRow();
					}
					num2 = 20;
				}
				num2 = 21;
				if (enumerator is IDisposable)
				{
					(enumerator as IDisposable).Dispose();
				}
				num2 = 22;
				clsReport.CloseTable();
				num2 = 23;
				clsReport.AddFooter(App.Title);
				num2 = 24;
				clsReport.Show();
				num2 = 25;
				PrintProgressEvent?.Invoke("Printing Complete");
				num2 = 26;
				clsShared.cSubs.NormalMouse();
			}
			catch (Exception obj) when ((obj is Exception && num != 0) & (num3 == 0))
			{
				ProjectData.SetProjectError((Exception)obj);
				/*Error near IL_027a: Could not find block for branch target IL_0246*/;
			}
			if (num3 != 0)
			{
				ProjectData.ClearProjectError();
			}
		}
	}
}
